package com.ysdzz.hadoop.wordcount;

import java.io.IOException;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

public class WordCountMapper extends Mapper<LongWritable, Text, Text, LongWritable> {

	@Override
	protected void map(LongWritable key, Text value, Mapper<LongWritable, Text, Text, LongWritable>.Context context)
			throws IOException, InterruptedException {
		String line = value.toString();
		String[] words = line.split("\\w+");
		LongWritable count = new LongWritable(1);
		if(null!=words && words.length>0){
			for(String word : words){
				context.write(new Text(word), count);
			}
		}
	}

	
	
}
